<form onsubmit="return false;" action="{:request()->url()}" data-auto="true" method="post" class='layui-form layui-card '
      autocomplete="off">

    <div class="layui-card-body">

        <div class="layui-form-item">
            <label class="layui-form-label label-required-prev">产品名称</label>
            <div class="layui-input-block">
                <input name="name" required value='{$vo.name|default=""}' placeholder="请输入产品名称" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label label-required-prev">所属分类</label>
            <div class="layui-input-block">            
            <select class="layui-select" name="product_class" required>
            	  <option style="display: none" value="">请选择所属分类</option>
                {foreach $product_class_op as $k=>$v}
                {if (isset($vo.product_class) and $vo.product_class eq $k)}
                <option selected value="{$k}">{$v}</option>
                {else}
                <option value="{$k}">{$v}</option>
                {/if}
                {/foreach}
            </select>
            </div>
        </div>
        <div class="layui-inline ">
            <label class="layui-form-label label-required-prev">商品缩略图：</label>
            <div class="layui-input-inline seller-inline-11">
                <div class="thumb_img">
                    <img alt="icon" style="height:200px; width: 200px;border: 1px solid #e6e6e6; display: block;" src="{$vo.thumb_img|default='__ROOT__/static/admin/img/jcfw.png'}"/>
                    <input type="hidden" name="thumb_img" required
                           value="{$vo.thumb_img|default=''}"
                           class="layui-input">
                    <span style="display: inline-block;padding-top: 20px;color: red">图片大小建议不超过2M，图片格式为jpg、jpeg、png</span>
                  
                    <div>
                        <a class="margin-top-10 layui-btn think-form-group-right  layui-btn-normal" 
                           data-type="jpg,png,jpeg" data-field="business_license" id='thumb_img'>上传图片</a>
                    </div>
                </div>
            </div>          
        </div>
        <div class="layui-form-item" style="margin-top: 20px;">
            <label class="layui-form-label">备注信息</label>
            <div class="layui-input-block">
                <textarea class="layui-textarea"  name="desc" >{$vo.desc|default=''}</textarea>
            </div>
        </div>

        <div class="hr-line-dashed"></div>
        {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}

        <div class="layui-form-item text-center">
            <button class="layui-btn" type='submit'>保存</button>
            <button class="layui-btn layui-btn-danger" type='button' data-close>取消</button>
        </div>
        <style>
            /* .uploadimage{display: none;} */
        </style>
        <script>window.form.render();
          layui.use('upload', function(){
            uplodImg('thumb_img');
            // uplodImg('image_mini');
            function uplodImg(id){
                var upload = layui.upload;
                var uploadInst = upload.render({
                    elem: '#'+id //绑定元素
                    ,url: "{:url('upload')}" //上传接口
                    ,accept:"images"
                    ,field:"image"
                    ,choose: function(obj){
                    	layer.load(); //上传loading
                    }
                    ,before: function (obj) { // 图片上传回调
								        obj.preview(function (index, picture, result) {
								            $("."+id+' img').attr("src", result);
								        });
								    }
                    ,done: function(res){
                    //上传完毕回调
												layer.closeAll('loading'); //关闭loading
                        if(res.code == 1){                          
                            $('[name="'+id +'"]').val(res.data)
                            $("."+id+' img').attr('src',res.data)                          
                        }
                    }
                    ,error: function(){
                    //请求异常回调
                    	layer.closeAll('loading'); //关闭loading
                    }
                });
            }   
      
        //执行实例
           
   
       
    });

        </script>
    </div>
</form>
